using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter21
{
	/// <summary>
	/// Example03: A Diesel Engine Cylinder
	/// Air at 20.0 C in the cylinder of a diesel engine is 
	/// compressed from an initial pressure of 1.0 atm and
	/// volume of 800.0 cm^3 to a volume of 60.0 cm^3. Assume
	/// that air behaves as an ideal gas with \gamma = 1.4 and
	/// that the compression is adiabatic. Find the final
	/// pressure and temperature of the air.
	/// p_f = 37.6 atm
	/// T_f = 553 C.
	/// </summary>
	public class Example03
	{
		public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.IdealGas gasi = new L.IdealGas();
			gasi.Temperature = 20.0+273.0;
			gasi.Volume = 800.0E-6;
			gasi.Pressure = 1013.0E2;
			gasi.RatioOfSpecificHeats = 1.4;
			L.IdealGas gasf = new L.IdealGas();
			gasf.Volume = 60.0E-6;
			gasf.Pressure = gasi.Pressure
				*Math.Pow(gasi.Volume/gasf.Volume,gasi.RatioOfSpecificHeats);
			gasf.Temperature = gasi.Temperature
				*gasf.Pressure*gasf.Volume
				/gasi.Pressure/gasi.Volume;
            result+=Convert.ToString(gasf.Pressure/1013.0E2)+"\r\n";
		    result+=Convert.ToString(gasf.Temperature-273.0)+"\r\n";
		}
	}
}
